<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width = device-width, initial-scale = 1.0, maximum-scale = 1.0, user-scalable = 0">
<meta http-equiv="Access-Control-Allow-Origin" content="*" />
<title>登录</title>

<link href="../../public/css/base.css" rel="stylesheet">
<link href="../../public/css/login.css" rel="stylesheet">
<script src="../../public/js/jquery.min.2.1.4.js"></script>
<script src="../../public/js/md5.js"></script>
<script src="../../public/js/sort_ascii.js"></script>
<script src="../../public/js/f_data.js"></script>
</head>

<body>
<div class="login">
	<div class="language">
		<span class="language-box">
			<i class="language-chn"></i>
		</span>
		
		<div class="choose-lang">
			<div class="choose-lang-box">
				<div class="choose-lang-btn">
					<i class="language-chn"></i>
					<span>中文</span>
				</div>
<!-- 
				<div class="choose-lang-btn">
					<i class="language-en"></i>
					<span>English</span>
				</div> -->
			</div>
			
		</div>
	</div>
	
	<div class="login-form">
		<form id="form" onsubmit="return false" action="##" method="post">
			<h1 class="login-logo">
				<img src="../../public/images/logo.png">
			</h1>
			
			<div class="login-form-group">
				<label class="icon-phone">手机号</label>
				<div class="input-group">
					<input placeholder="请输入手机号" name="mobile">
					<i class="clear-keyword"></i>
				</div>
			</div>
			
			<div class="login-form-group">
				<label class="icon-pw">登录密码</label>
				<div class="input-group">
					<input type="password" placeholder="请输入登录密码" name="password">
					<i class="clear-keyword"></i>
				</div>
			</div>
			
			<div class="login-form-group">
				<label class="icon-code">验证码</label>

				<div class="input-group form-code">
					<input placeholder="请输入图中的字符" name="yzm" id="yzm" maxlength="10">
					<i class="clear-keyword"></i>

					<img id="yzm" src="http://app.bai918.com/index.php/api/Yzm/login_yzm"  onclick="this.src=url+'/index.php/api/Yzm/login_yzm?' + Math.random();">
				</div>
			</div>
			
			<div class="login-submit">
				<button type="submit" onclick="insert()">提交</button>
			</div>
			
			<div class="login-links">
				<a href="../register/register.html" class="login-links-1">立即注册</a>
				<a href="FindPW.html" class="login-links-2">忘记密码？</a>
			</div>
		</form>
	</div>
</div>

<script type="text/javascript">
		function insert() {
			var mobile = $("input[name=mobile]").val();
			var password = $("input[name=password]").val();
			var yzm = $("input[name=yzm]").val();
			var time = Date.parse(new Date())/1000;
		    let datas = {mobile,password,yzm,time};
		    let s_data = sort_ascii(datas);
			var code = sort_code(s_data);
            $.ajax({
                type: "POST",//方法
                url: url+"/index.php/api/User/login" ,//表单接收url
                data: {mobile:mobile,password:password,yzm:yzm,code:code,time:time},
                success: function(msg) {
                  //提交成功的提示词或者其他反馈代码
					if(msg.code == 1){
						setCookie('uid',msg.data.u_id,1);
						setCookie('token',msg.data.user_token,1);
						// alert(url+"/index.php/api/User/login");
						location.href="http://www.xsy.com/web/home/index.html";
					}

					if(msg.code == 0){
						alert(msg.msg);
					}
                },
                error : function() {
                  //提交失s败的提示词或者其他反馈代码
                    alert('失败！');
                }
            });
        }

	$(function(){
		$('.language-box').click(function(){
			$('.choose-lang').fadeIn();
		});
		
		$('.choose-lang').click(function(){
			 $(this).fadeOut();
		});
	});
</script>
</body>
</html>
